fix: cancel sandbox proxy iframe timeout on effect cleanup to prevent StrictMode unhandled rejection#190
Conversation
… StrictMode unhandled rejection Co-authored-by: claude <noreply@anthropic.com>
|
@idosal hey wanted to check on this, is any chance we can merge this so I can stop using a patched version? |
Sorry @matsjfunke , completely missed this PR. I'll go over it tomorrow. |
|
@idosal Hey I'm just following up here to see if this can be merged in at some point? CC: @matsjfunke |
There was a problem hiding this comment.
Pull request overview
This PR addresses React StrictMode effect double-invocation in the TypeScript client by adding a cancellation mechanism so sandbox iframe readiness timeouts can be cleared during effect cleanup, preventing later unhandled rejections.
Changes:
- Extend
setupSandboxProxyIframeto accept an optional mutable cancel ref that can clear the pending timeout/listeners. - Wire the cancel ref into
AppFrame’s effect cleanup to cancel in-flight sandbox setup during teardown. - Update
AppFrametests and add a lifecycle test covering the StrictMode cleanup timing scenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
sdks/typescript/client/src/utils/app-host-utils.ts |
Adds SandboxCancelRef and exposes a synchronous cancellation hook for the sandbox iframe readiness flow. |
sdks/typescript/client/src/components/AppFrame.tsx |
Creates/passes a cancel ref into iframe setup and invokes it during effect cleanup. |
sdks/typescript/client/src/components/__tests__/AppFrame.test.tsx |
Updates expectations for the new function signature and adds a StrictMode-oriented lifecycle test. |
…ready message with jsdom contentWindow mock
…idate SandboxCancelRef documentation
|
Thanks for the contribution @matsjfunke, truly appreciated! |
|
🎉 This PR is included in version 7.1.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |

This adresses the issue with react strictmode mentioned in the Issue I raised